<template>
    <h1>登录页面</h1>

    <table>
        <tr>
            <td>账号</td>
            <td>
                <input type="text" v-model="Name">
            </td>
        </tr>

        <tr>
            <td>密码</td>
            <td>
                <input type="password" v-model="PWd">
            </td>
        </tr>

        <tr>
            <td colspan="2">
                <input type="button" value="登录" @click="Login" >
            </td>
        </tr>

    </table>

</template>

<script setup lang="ts">

import { ref } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';

const router = useRouter();

const Name = ref('');
const PWd = ref('');

const Login = ()=>{
    axios({
        method:'get',
        url:'http://localhost:61480/api/Regoin/Login',
        params:{
            Name:Name.value,
            PWd:PWd.value
        }
    })
    .then(res=>{
        console.log(res.data);
        if(res.data!=null){
            alert('登录成功');
            router.push('./ShowUser');
        }
        else{
            alert('登录失败');
        }
    })
    .catch(err=>{
        console.log(err);
    })
}


</script>